package ex403;

import ex403.point.Point2D;
import ex403.point.Point2DSet;

import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Point2DSet points = new Point2DSet();

        Scanner input = new Scanner(System.in);
        System.out.print("需要输入的坐标个数: ");
        int n = input.nextInt();

        for (int i = 0; i < n; i++) {
            System.out.printf("第%d个横坐标和纵坐标(x y): ", i + 1);
            Point2D p = new Point2D(input.nextDouble(), input.nextDouble());
            points.addPoint2D(p);
        }

        points.update();
        System.out.printf("\n实际共有%d个点\n", points.getNumberOfPoint2D());
        System.out.println(points);

        System.out.printf("距离最近: %s, 距离是: %.2f\n", points.getNearestPair(), points.getNearestPair().getDistance());
        System.out.printf("距离最远: %s, 距离是: %.2f\n", points.getFarthestPair(), points.getFarthestPair().getDistance());
    }
}
